<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue生命周期函数</title>
    <script src="https://unpkg.com/vue@next"></script>
    <!-- 
        使用v-for进行循环的时候,一定要给一个key值.这样可以避免重复渲染 
        1.使用数组的变更函数 push,pop ,shift,unshift,splice,sort,reverse
        2.v-for还可以循环一个数字
        3.template占位符
    -->
</head>
<body>
    <div id="root"></div>
    <script>
        // vue的生命周期函数
        const app = Vue.createApp({
            data() {
                return {
                    list: ['dell','lee','teacher']
                }
            },
            methods: {
                btn(){
                    // this.list.push('hello')
                    // this.list= ['dl','l','a']
                    // 连接数组
                    this.list = ['dl','l','a'].concat(['ggg'])
                }
                
            },
            template:
            `<div>
                <div v-for='(item,index) in list' :key='index'>
                    {{item}}-->{{index}}
                </div>    
                <button @click='btn'>添加</button>
            </div>`
        });
        const vm = app.mount('#root');
    </script>
</body>
</html>